package com.itheima.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.common.result.JsonResult;
import com.itheima.entity.Orders;
import com.itheima.entity.dto.OrdersDto;
import com.itheima.service.OrdersDetailsService;
import com.itheima.service.OrdersService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zhengbinghua
 * @since 2023-03-02
 */
@RestController
@RequestMapping("/orders")
@Api(tags = "订单管理")
public class OrdersController {
    @Autowired
    private OrdersService ordersService;
    @Autowired
    private OrdersDetailsService ordersDetailsService;
    @PostMapping("submit")
    @ApiOperation(value = "订单结算")
    public JsonResult submitOrder(@RequestBody Orders orders){
        ordersService.submit(orders);
        return JsonResult.success("下单成功！");
    }
@GetMapping("userPage")
    public JsonResult getOrderPageInfo(Integer page, Integer pageSize){
       Page<OrdersDto> dtoPage= ordersService.userpage(page,pageSize);
        return JsonResult.success(dtoPage);
    }

}
